package cn.z2huo.demo.mapstruct.controller;

import cn.z2huo.demo.mapstruct.convert.user.UserConvert;
import cn.z2huo.demo.mapstruct.dataobject.UserDO;
import cn.z2huo.demo.mapstruct.dataobject.UserRoleRelationDO;
import cn.z2huo.demo.mapstruct.service.UserServiceImpl;
import cn.z2huo.demo.mapstruct.vo.UserVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *
 * @author z2huo
 */
@Component
@RequiredArgsConstructor
public class UserController {

    private final UserServiceImpl userService;

    public UserVO getUserByCode(String userCode) {
        UserDO user = userService.getUserByCode(userCode);
        return UserConvert.INSTANCE.convert(user);
    }

    public UserVO getUserInfo(String userCode) {
        UserDO userByCode = userService.getUserByCode(userCode);
        List<UserRoleRelationDO> userRoleList = userService.getUserRoleList(userCode);
        return UserConvert.INSTANCE.convert(userByCode, userRoleList);
    }

}
